import pymysql
import sys
from AIDetector_pytorch import Detector
from threading import Thread
import cv2
import os
import time
import traceback
import plotline
from flask import jsonify
from retinaface import Retinaface
class mysql_connector():
    def get_connector(self):
        conn=pymysql.connect(host = '121.4.41.228' # 连接名称，默认127.0.0.1
        ,user = 'alarmuser' # 用户名
        ,passwd='123456' # 密码
        ,port= 3306 # 端口，默认为3306
        ,db='alarm' # 数据库名称
        ,charset='utf8' # 字符编码
        )
        return conn
    def get_cur(self,conn):
        cur = conn.cursor() # 生成游标对象
        return cur
    def test_select(self,cur,conn):
        sql = 'select * from  monitor_border_config'
        try:
            cur.execute(sql) # 执行SQL语句
            result = cur.fetchall()
        except:
            result = {}
            traceback.print_exc()
        print(result)
     def update_monitor_border_config(self,cur,conn,monitor_id,linelist,pointlist,draw_index,typelist):
        sql = "update  monitor_border_config set linelist = %s,pointlist = %s, draw_index = %s, type_list = %s where monitor_id = %s;"
        try:
            status = cur.execute(sql,(linelist,pointlist,draw_index,typelist,monitor_id)) # 执行SQL语句
            conn.commit()
        except:
            traceback.print_exc()
            status = 0
        return status
if __name__ == '__main__':
    conn = mysql_connector().get_connector()
    cur = mysql_connector().get_cur(conn)
    mysql_connector().test_select(cur,conn)
        
        